package com.yixun.qfbao.hander;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.yixun.qfbao.api.service.PremisesAndCaseMemberService;
import com.yixun.qfbao.apidto.PremisesAndCaseMemberResDto;
import com.yixun.qfbao.apidto.StaffPremiseRelReqDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.StaffPrimiseRelReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 
 * @author zilong.liu
 * @date  2020-7-23 
 * @desc
 * 		 获取员工的驻场楼盘信息并返回
 */
@Component
public class GetPremisesAndCaseMemberByStaffIdHandler extends CommonAbstractHander{

	private static final Logger LOGGER = LoggerFactory.getLogger(GetPremisesAndCaseMemberByStaffIdHandler.class);
	
	@Autowired
	PremisesAndCaseMemberService premisesAndCaseMemberService;
	
	/**
	 * 获取驻场员工的楼盘信息并返回
	 */
	@Override
	@SuppressWarnings("rawtypes")
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		StaffPrimiseRelReqVo req = (StaffPrimiseRelReqVo)reqDto;
        StaffPremiseRelReqDto reqDto1 = req.getParams();
        BaseResponseDTO<PremisesAndCaseMemberResDto> res = new BaseResponseDTO<>();
        res.setResult(ResultEnum.FAIL.getNo());
        try {
        	PremisesAndCaseMemberResDto premisesAndCaseMemberResDto = new PremisesAndCaseMemberResDto();
        	List<Map<String, Object>> premisesAndCaseMemberList = 
        			premisesAndCaseMemberService.getPremisesAndCaseMemberByStaffId(reqDto1);
			premisesAndCaseMemberResDto.setPremisesAndCaseMemberList(premisesAndCaseMemberList);
            res.setResult(ResultEnum.SUCCESS.getNo());
            res.setResData(premisesAndCaseMemberResDto);
            return res;
        }catch (Exception e){
        	LOGGER.error("GetPremisesAndCaseMemberByStaffIdHandler exception: {}", e);
            res.setResult(ResultEnum.FAIL.getNo());
            res.setErrorMsg("根据员工信息查询对应的楼盘失败");
        }
        return res;
	}

}
